package com.atguigui.leetcode;

/**
 * 672.灯泡开关 Ⅱ
 * Project: leetcode
 * Package: com.atguigui.leetcode
 * Version: 1.0
 * <p>
 * Created by WJX on 2022/9/15 8:47
 */
public class P672BulbSwitcherIi {
    public static void main(String[] args) {
        Solution solution = new P672BulbSwitcherIi().new Solution();
        // TO TEST
    }

    //leetcode submit region begin(Prohibit modification and deletion)
    class Solution {

        public int flipLights(int n, int presses) {
            //不按开关   1
            if (presses == 0) {
                return 1;
            }
            //特殊情况处理   2
            if (n == 1) {
                return 2;
            } else if (n == 2) {
                //特殊情况   3  4
                return presses == 1 ? 3 : 4;
            } else {
                //n >= 3    4 7 8
                return presses == 1 ? 4 : presses == 2 ? 7 : 8;
            }
        }
    }
}
